package edu.gmu.projects.fireresponder.plan;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

public class PlanObjectives {
	private ArrayList<PlanObjective> objectives;
	
	public ArrayList<PlanObjective> getObjectives() {
		return objectives;
	}

	public void setObjectives(ArrayList<PlanObjective> o) {
		objectives = o;
	}
	
	public void add(PlanObjective o) {
		objectives.add(o);
	}
	
	public boolean remove(PlanObjective o) {
		return objectives.remove(o);
	}
	
	public Iterator<PlanObjective> iterator() {
		return objectives.iterator();
	}	

	public static void main(String[] args) {
		try {
			InputStream stream = new FileInputStream("/Users/gpian/Documents/workspace/first-responder/assets/json/mission-plan-data-1.json");
			ObjectMapper mapper = new ObjectMapper();
			try {
				PlanObjectives objectives = mapper.readValue(stream, PlanObjectives.class);
				
				for (PlanObjective o : objectives.getObjectives()) {
					if (o instanceof PlanRoute)
					{
						PlanRoute r = (PlanRoute)o;
						System.out.println(r.getRoute().get(0));
					}
				}
			} catch (JsonParseException e) {
				e.printStackTrace();
			} catch (JsonMappingException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

	}
}